<#import "/macro/pmmacro.ftl" as pmmacro >
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="${basepath}/css/pm.css" type="text/css">
<style type="text/css">
body{
	padding:0px;
	margin:0px;
}
#divresult table{
	width: 99%;
	margin-top:20px;
}
#divresult table th,td{
	border: 1px solid #cccccc;
	font-size: 14px;
	font-family: serif;
	text-align :left;
}
</style>
</head>

<body>

<div id="divresult" style="min-height:300px;">
<div>
<table id="material_table" cellpadding="0" cellspacing="0">
	<thead>
		<tr style="backgroud-color:#bbeeff;">
			<td>物料名称</td>
			<td>库存数量</td>
			<td>领取数量</td>
		</tr>
	</thead>
	<tbody id="material_tbody">
		<#list pager.result as material>
			<tr>
				<td>${material.materialName!""}</td>
				<td>
					${material.inventoryNumber}(${material.materialUnit!""})						
				</td>
				<td colspan="2">
					<input type="text" />-${material.materialUnit!""}
					<input type="button" value="添加" onclick="javascript: appendtoform(${material.id},'${material.materialName}',this);" /> 
				</td>
			</tr>
		</#list>
	</tbody>
	<tfoot>
		<tr>
			<td colspan="4">
				<@pmmacro.pagetoolv2 formid="materialform"/>
			</td>
		</tr>
	</tfoot>
</table>
</div>
</div>
</body>
<script type="text/javascript" src="${basepath}/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript">
(function(){
	window.parent.document.getElementById("result_page").scrolling='no';
})();
<#--添加-->
function appendtoform(materialId,materialName,thisz){
	var inventoryNumber = $(thisz).prev().attr("value");
	var collarul =  window.parent.document.getElementById("collarul");
	var idelem = window.parent.document.getElementById("material"+materialId);	
	var val = materialId+"_"+inventoryNumber;
	if(idelem){
		$(idelem).attr("value",val);
		$(idelem).prev().html(inventoryNumber);
	}else{
		var html = "<li><a href='javascript:;' title='取消' onclick='javascript: removecollar(this);'>&nbsp;X&nbsp;</a>"
				+materialName + ":<label>"+inventoryNumber+"</label>"
				+"<input name='collarlogs' value='"+val+"' id='material"+materialId+"' type='hidden' />"
				+"</li>";
		$(collarul).append(html);
		$(window.parent.document.getElementById("collarmaterialdiv")).show();
	}
}

</script>
</html>